<html>
<head>
<title>直方图</title>
</head>
<script src="echarts.js"></script>
<script src="ecStat.js"></script>

<script>

var height = [70, 65, 63, 72, 81, 83, 66, 75, 80, 75, 79, 76, 76, 69, 75, 74, 85, 86, 71, 64, 78, 80, 74, 72, 77, 81, 82, 80, 80, 80, 87];

var bins = ecStat.histogram(height);

</script>
<body>
    <div id="main" style="width: 600px;height:400px;"></div>

<script>
        var myChart = echarts.init(document.getElementById('main'));

var option = {
    color: ['rgb(25, 183, 207)'],
    grid: {
        left: '3%',
        right: '3%',
        bottom: '3%',
        containLabel: true
    },
    xAxis: [{
        type: 'value',
        //这个一定要设，不然barWidth和bins对应不上
        scale: true,
    }],
    yAxis: [{
        type: 'value',
    }],
    series: [{
        type: 'line',
        barWidth: '99.3%',
        label: {
            normal: {
                show: true,
                position: 'insideTop',
                formatter: function (params) {
                    return params.value[1];
                }
            }
        },
        data: bins.data
    }]
};

        myChart.setOption(option);

</script>

</body>

</html>